package com.xnew.utils;

import okhttp3.*;

import java.io.IOException;

/**
 * @name: HttpUtils
 * @author: duroper
 * @create: 2020/02/27
 */
public class HttpUtils {

    /* Maybe not thread safe !!! */
    private static OkHttpClient client = new OkHttpClient();

    public static Response post(String url, String data, String sign) throws IOException {
        FormBody formBody = new FormBody.Builder()
                         .add("data",data)
                         .add("sign",sign)
                         .build();
        Request request = new Request.Builder()
                .url(url)
                .post(formBody)
                .build();
        return client.newCall(request).execute();
    }

    public static Response get(String url) throws IOException {
        Request request = new Request.Builder()
                .url(url)
                .build();
        return client.newCall(request).execute();
    }

}